<?php

namespace App\Http\Controllers;

use Laravel\Lumen\Routing\Controller as BaseController;

class Controller extends BaseController
{
	public function jsonResponse($error,$result="",$message=""){
		if($message == "paramError") $message = $result->first();
		else $message = $this->trans($message);
		return response()->json(["error"=>$error,"result"=>$result,"message"=>$message]);
	}
	
	private function trans($key){
		$arr = require __DIR__."/../../../resources/lang/".env("APP_LOCALE")."/tip.php";
		return isset($arr[$key])?$arr[$key]:$key;
	}
}
